using UnityEngine;

public class Rating : MonoBehaviour
{
	[SerializeField]
	private Graphic graphic;

	[SerializeField]
	private GameObject starLayout;

	[SerializeField]
	private GameObject ratingLayout;

	[SerializeField]
	private GameObject fourStarLayout;

	[SerializeField]
	private GameObject threeStarLayout;

	public int Rated
	{
		get
		{
			return PlayerPrefs.GetInt("Rated", 0);
		}
		set
		{
			PlayerPrefs.SetInt("Rated", value);
		}
	}

	public void Rate(int rate)
	{
		Rated = 1;
		RateAnimate(rate);
		switch (rate)
		{
		case 1:
		case 2:
		case 3:
			Invoke("Rating3Star", 0.5f);
			break;
		case 4:
			Invoke("Rating4Star", 0.5f);
			break;
		case 5:
			Invoke("Rating5Star", 0.5f);
			break;
		}
	}

	private void RateAnimate(int rate)
	{
		ratingLayout.SetActive(value: false);
		for (int i = 0; i < starLayout.transform.childCount; i++)
		{
			if (i + 1 <= rate)
			{
				starLayout.transform.GetChild(i).GetComponent<Animation>().Play("Rating Star");
			}
		}
	}

	private void Rating3Star()
	{
		starLayout.SetActive(value: false);
		threeStarLayout.SetActive(value: true);
	}

	private void Rating4Star()
	{
		starLayout.SetActive(value: false);
		fourStarLayout.SetActive(value: true);
	}

	private void Rating5Star()
	{
		Close();
		Application.OpenURL("market://details?id=com.idle.tycoon.miner.clicker.inc.ikame");
	}

	public void Close()
	{
		graphic.ShowPopup(value: false, Graphic.Dialog.Rating);
	}

	public void Feedback()
	{
		Close();
		Application.OpenURL("https://docs.google.com/forms/d/e/1FAIpQLScMVsBd8qkUBXq4z7QvmMuQ_lORK6JC_zKCo0_YUcwSowo4gw/viewform");
	}
}
